/** * This code is part of the Bumpslide Library by David Knape * http://bumpslide.com/ *  * Copyright (c) 2006, 2007, 2008 by Bumpslide, Inc. *  * Released under the open-source MIT license. * http://www.opensource.org/licenses/mit-license.php * see LICENSE.txt for full license terms */ package app.view {	import com.bumpslide.events.UIEvent;	import com.bumpslide.ui.Box;	import com.bumpslide.ui.Lightbox;	/**	 * This is the main view component created by the application	 * 	 * Since it extends AppComponent and not just Component,	 * it has access to our application Model and Service loader	 *  	 * @author David Knape	 */	public class MainView extends AppComponent 	{
		// child display objects		public var background:Box;		public var header:Header;		public var sectionHolder:SectionContent;		private var imagePopup:ImagePopup;
				/**		 * Initialize children, event listeners, and bindings		 */		override protected function addChildren():void 		{			super.addChildren();									updateDelay = 0;						background = new Box(0xcccccc);			background.alpha = .5;			addChild(background);						// create content holder			sectionHolder = new SectionContent();						addChild(sectionHolder);        	        				// create header			header = new Header();			addChild(header);						imagePopup = new ImagePopup();			addChild(imagePopup);							// bind selected image to image popup			model.bind('selectedImageUrl', imagePopup, 'url'); 						// listen for UI events...			addEventListener(Lightbox.EVENT_CLOSED, handlePopupClose);			addEventListener(Header.EVENT_LOGO_CLICK, handleLogoClick);		}				/**		 * Update display list		 */
		override protected function draw():void 		{				background.setSize(width, height);						header.setSize(width, 48);						sectionHolder.move(20, header.height + 20);			sectionHolder.setSize(width - 40, (height - header.height) - 40);			imagePopup.move(-x, -y);			super.draw();
		}
				/**		 * On logo click, go to first section (home)		 */ 		private function handleLogoClick(event:UIEvent):void 		{			model.currentSection = 0;		}				/**		 * Update state when popup is closed		 */		private function handlePopupClose(event:UIEvent):void 		{			model.selectedImageUrl = null;		}	}}